#ifndef PIECE_HPP
#define PIECE_HPP
#include <iostream>
#include <string>
#include "coordinate.hpp"
#include "gamemap.hpp"
#include "piece_type.hpp"

//红方和黑方
#define RED false
#define BLACK true

#define X_MAX 10
#define Y_MAX 9

using std::ostream;
using std::string;

class Piece{
	private:
	protected:
		Coordinate coor;
		//判断队伍和是否存活，存活为true
		bool color, life;
		enum PieceType pt;

		Piece() = default;

		void updateCoor(GameMap &, const Coordinate &)noexcept;

	public:
		Piece(PieceType pt):pt(pt){}

		Piece(const Coordinate &coor):coor(coor){}

		Piece(const Piece &pie);

		Piece(Piece &&pie);

		//设置坐标
		void setCoor(const Coordinate &coor)noexcept{ this->coor = coor; }

		inline const Coordinate &getCoor()const noexcept{ return coor; }

		inline bool getColor()const noexcept{ return color; }

		inline bool isLife()const noexcept{ return life; }

		inline void setColor(bool co)noexcept{ color = co; }

		inline void setLife(bool li)noexcept{ life = li; }

		//移动棋子
		virtual bool move(const Coordinate &coor){ return false; }

		//用于重新初始化棋子的位置和life
		virtual void init(){}

		//将棋子写在地图上
		virtual void draw(GameMap &gm)const{ gm[coor] = pt; }

		virtual Piece &operator=(const Piece &) = delete;

		virtual Piece &operator=(Piece &&);

		virtual ~Piece(){}

		friend ostream &operator<<(ostream &, const Piece &);
};

extern Piece *pieces[33];

#endif
